﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using Assets.Scripts.Net.Data.Model;
using Debug = UnityEngine.Debug;

namespace Assets.Scripts.Net.Data.Reader
{
    /// <summary>
    /// 答案信息
    /// </summary>
    public class AnsInfoReader:NetInfoReaderBase
    {
        public AnsInfoReader(List<object> list, Action<Dictionary<string, string>> action) : base(list, action)
        {
            if(list==null)return;
            Dictionary<string,string> resUrlDict =new Dictionary<string, string>();
            List<AnsInfo> infos = new List<AnsInfo>();
            for (int i = 0; i < list.Count; i++)
            {
                AnsInfo info = new AnsInfo();
                Dictionary<string, object> dict = list[i] as Dictionary<string, object>;
                AutoSetValue<AnsInfo>(dict, info);
                infos.Add(info);
                if (!string.IsNullOrEmpty(info.respath))
                {
                    //Debug.Log("答案的资源路径是："+info.respath);
                    resUrlDict.Add("A_" + info.id, info.respath);//ResPath Url的路径
                }
            }
            AddInfoToFactory<List<AnsInfo>>(infos);
            if (action != null) action(resUrlDict);
        }
    }
}